package com.yjjxt

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object Hello03Action {
  def main(args: Array[String]): Unit = {
    //1配置并创建对象
    val sparkContext = new SparkContext((new SparkConf().setMaster("local").setAppName("Hello02Transformation" + System.currentTimeMillis())))
    //2开始读取数据
    val lines: RDD[String] = sparkContext.textFile("src/main/resources/user.log")

    //3开始计算(计数)
    println(lines.count())
    lines.foreach(ele => println("foreach:" + ele))
    lines.take(5).foreach(ele => println("take:" + ele))
    println(lines.first())
    lines.collect().foreach(ele => println("collect:" + ele))

  }
}
